#include "ServoSg90.h"


CServoSG90::CServoSG90()
{
}

CServoSG90::~CServoSG90()
{
}

ServoRet_t CServoSG90::Init(int pin)
{
	ServoRet_t ret = CServoPWM::Init(pin);
	if (ret == SERVO_RET_SUCCESS) {
		m_servo.attach(pin, 500, 2400);
	}

	return ret;
}

void CServoSG90::Uninit()
{
	m_servo.detach();
	CServoPWM::Uninit();
}

bool CServoSG90::IsOffsetSupport()
{
	return false;
}

ServoRet_t CServoSG90::SetAngle(uint16_t angle, uint32_t msec)
{
	m_servo.write(angle);
	return SERVO_RET_SUCCESS;
}

ServoRet_t CServoSG90::GetAngle(uint16_t &angle)
{
	angle = m_servo.read();
	return SERVO_RET_SUCCESS;
}

ServoRet_t CServoSG90::SetOffset(int16_t offset)
{
	return SERVO_RET_UNSUPPORT;
}

ServoRet_t CServoSG90::GetOffset(int16_t &offset)
{
	return SERVO_RET_UNSUPPORT;
}

ServoRet_t CServoSG90::SetId(uint8_t newid)
{
	return SERVO_RET_UNSUPPORT;
}

ServoRet_t CServoSG90::SetLed(bool on)
{
	return SERVO_RET_UNSUPPORT;
}

ServoRet_t CServoSG90::Terminate()
{
	return SERVO_RET_UNSUPPORT;
}

ServoRet_t CServoSG90::GetFirmware(uint32_t &firmware)
{
	return SERVO_RET_UNSUPPORT;
}

ServoRet_t CServoSG90::Lock()
{
	return SERVO_RET_UNSUPPORT;
}

ServoRet_t CServoSG90::Unlock()
{
	return SERVO_RET_UNSUPPORT;
}

